package cn.lili.modules.system.entity.dos;

import cn.lili.mybatis.model.BaseStandardEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.springframework.util.Assert;

/**
 * <p>
 * 商品授权设置
 * </p>
 *
 * @author liuyang
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("li_auth")
@ApiModel(value="LiAuth", description="商品授权设置")
public class LiAuth extends BaseStandardEntity implements Serializable {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "服务名")
    @TableField("title")
    private String title;

    @ApiModelProperty(value = "编号")
    @TableField("sn")
    private String sn;

    @ApiModelProperty(value = "appid")
    @TableField("appid")
    private String appid;

    @ApiModelProperty(value = "公钥")
    @TableField("public_key")
    private String publicKey;

    @ApiModelProperty(value = "私钥")
    @TableField("private_key")
    private String privateKey;

    @ApiModelProperty(value = "开通时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("open_time")
    private Date openTime;

    @ApiModelProperty(value = "权限")
    @TableField("auth")
    private String auth;

    @ApiModelProperty(value = "回调地址")
    @TableField("callback_url")
    private String callbackUrl;

    @ApiModelProperty(value = "状态（1正常，0冻结,默认1）")
    @TableField("type")
    private Integer type;


    /**
     * 新增/修改空值校验
     * */
    public void notNull(){
        Assert.notNull(this.getTitle(),"服务名不能为空");
        Assert.notNull(this.getAppid(),"APPID不能为空");
        Assert.notNull(this.getPublicKey(),"公钥不能为空");
        Assert.notNull(this.getPrivateKey(),"私钥不能为空");
        Assert.notNull(this.getAuth(),"权限不能为空");
        Assert.notNull(this.getCallbackUrl(),"回调地址不能为空");
    }
}
